package com.demo.interceptor;

import javax.servlet.http.HttpServletRequest;

import com.demo.common.constant.DictKeys;
import com.demo.common.model.Article;
import com.demo.common.model.Tag;
import com.demo.tools.ToolWeb;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

public class CommonInterceptor implements Interceptor{

	@Override
	public void intercept(Invocation ai) {
		 HttpServletRequest request = ai.getController().getRequest();
		 request.setAttribute("baseUrl", DictKeys.getBaseUrl());
		 request.setAttribute("basePath", ToolWeb.getContextPath(request));
		 //浏览排行
		 request.setAttribute("article_br", Article.me.orderByBrowse());
		 //评论排行
		 request.setAttribute("article_cm", Article.me.orderByComment());
		 //站长推荐
		 request.setAttribute("article_recm", Article.me.ArticleRecommend());
		 //热门标签
		 request.setAttribute("hotTags", Tag.me.hotTags());
		 System.out.println(ToolWeb.getContextPath(request));
		 ai.invoke();
		
	}

}
